package com.paton.Selenium;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;


@Listeners({TestngListenerScreenShot.class})
public class Login extends BaseDriver{
	
	String userAccount = "13051528719";
	String password = "zpf19950214";
	
	public void initDriver() {
		String BASEURL = "https://www.imooc.com/";
		driver = new ChromeDriver();
		driver.get(BASEURL);
		driver.manage().window().maximize();
	}
	
	
	public void loginScript() throws InterruptedException, IOException {		
		WebElement loginIcon =this.element(this.byStr("signButton"));
		loginIcon.isDisplayed();
		loginIcon.click();
		Thread.sleep(2000);
		WebElement userInput = this.element(this.byStr("userInput"));
		userInput.isDisplayed();
		WebElement pswInput = this.element(this.byStr("pwdInput"));
		pswInput.isDisplayed();
		WebElement loginButton = this.element(this.byStr("loginButton"));
		loginButton.isDisplayed();
		
		userInput.sendKeys(userAccount);
		pswInput.sendKeys(password);
		loginButton.click();
	}	
}
	
	
	


